<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML>

<TITLE>SugarCRM SQL Editor</TITLE>
<META charset="utf-8"/>


<HEAD>

   <link rel="stylesheet" href="../../../skins/plugins/sql/codemirror/lib/codemirror.css"/>
   <link rel="stylesheet" href="../../../skins/plugins/sql/codemirror/addon/hint/show-hint.css"/>
   <link rel="stylesheet" href="../../../skins/plugins/sql/datatables/css/jquery.dataTables.min.css"/>
   <link rel="stylesheet" href="../../../skins/plugins/sql/datatables/extensions/buttons/buttons.dataTables.min.css"/>

   <link href="../../../skins/plugins/font-awesome/font-awesome.css?v=4.4.0" rel="stylesheet">
   <link href="../../../skins/plugins/animate.css" rel="stylesheet">

   <link rel="stylesheet" href="../../../skins/plugins/layui/css/layui.css">


   <style>
      .CodeMirror {
         width: 100%;
         /*border: 1px solid black;*/
      }
      div::-webkit-scrollbar-track {
         background-color: #F5F5F5;
      }

      div::-webkit-scrollbar {
         width: 6px;
         background-color: #F5F5F5;
      }

      div::-webkit-scrollbar-thumb {
         background-color: #999;
      }

      .layui-table[lay-data] {
         display: block !important;
      }
   </style>

</HEAD>


<BODY>

<div class="layui-row layui-col-space5" style="min-height: 406px">
   <div class="layui-col-sm6 layui-col-md9">

      <div class="layui-card no-space" style="margin: 0px;">
         <div class="layui-card-header">
            SJ人口分析
            <div class="layui-btn-group" style="float: right">
               <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="run_sql()"><i class="fa fa-play"></i></button>
               <button type="button" class="layui-btn layui-btn-primary layui-btn-sm"><i class="fa fa-pause"></i></button>
               <button type="button" class="layui-btn layui-btn-primary layui-btn-sm"><i class="fa fa-save"></i></button>
               <button type="button" class="layui-btn layui-btn-primary layui-btn-sm"><i class="fa fa-trash"></i></button>
               <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" id="toggleSQL" onclick="toggleSQL()"><i class="fa fa-angle-double-up"></i></button>
            </div>
         </div>
         <div class="layui-card-body" style="padding: 0px;">
            <form id="sql-form">
               <textarea id="code" name="code">
-- show tables;
-- DESCRIBE -tableName-;
select a.access,b.data from cdn_access_statistic a ,cdn_access_data b where a.access = b.access;
               </textarea>
            </form>
         </div>
      </div>


      <div class="layui-card" style="margin-top: 5px;">
         <div class="layui-card-body" style="padding: 0px;">
            <div class="layui-tab" style="height: 400px">
               <ul class="layui-tab-title">
                  <li class="layui-this">运行结果</li>
                  <li>运行日志</li>
                  <li>运行历史</li>
                  <div class="layui-btn-group" style="float: right;padding: 5px;">
                     <button type="button" style="float: right;" class="layui-btn layui-btn-sm" data-type="isAll">导出</button>
                  </div>
               </ul>
               <div class="layui-tab-content" style="padding: 0px;">
                  <div class="layui-tab-item " id="data-container" style="text-align: center"><table id="demo" lay-filter="userFilter"></table></div>
                  <div class="layui-tab-item layui-show "  id="data-error" style="text-align: center">暂无数据，请先运行任务!</div>
                  <div class="layui-tab-item" id="data-run" style="text-align: center">任务正在运行，请稍后任务!</div>
               </div>
            </div>
         </div>
      </div>
   </div>
   <div class="layui-col-sm6 layui-col-md3">
      <div class="layui-card no-space" style="margin: 0px;">
         <div class="layui-card-header">数据资源</div>
         <div class="layui-card-body" style="padding: 0px 15px;">
            <form class="layui-form" action="">
               <select name="modules" lay-verify="required" lay-search="">
                  <option value="">请选择数据源</option>
                  <option value="1" selected>10.106.1.190-原始库</option>
                  <option value="2">资源库</option>
                  <option value="3">主题库</option>
               </select>
               <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入数据资源名称查询" class="layui-input" >
            </form>
            <div id="dataTree" style="height: 638px;overflow-y: scroll;-webkit-scrollbar-thumb:"></div>
         </div>
      </div>

   </div>
</div>

<script src="../../../skins/plugins/sql/js/jszip.min.js"></script>
<script src="../../../skins/plugins/sql/codemirror/lib/codemirror.js"></script>
<script src="../../../skins/plugins/sql/codemirror/addon/hint/show-hint.js"></script>
<script src="../../../skins/plugins/sql/codemirror/addon/hint/sql-hint.js"></script>
<script src="../../../skins/plugins/sql/codemirror/mode/sql/sql.js"></script>

<script src="../../../skins/plugins/sql/js/jquery-2.2.0.min.js"></script>
<script src="../../../skins/plugins/sql/datatables/js/jquery.dataTables.min.js"></script>
<script src="../../../skins/plugins/sql/datatables/extensions/buttons/dataTables.buttons.min.js"></script>
<script src="../../../skins/plugins/sql/datatables/extensions/buttons/buttons.html5.min.js"></script>
<script src="../../../skins/plugins/sql/datatables/extensions/buttons/buttons.flash.min.js"></script>

<script src="../../../skins/plugins/layui/layui.all.js"></script>
<script>
   layui.use(['element', 'layer'], function(){
      var element = layui.element;
      var layer = layui.layer;

      //监听折叠
      element.on('collapse(test)', function(data){
         layer.msg('展开状态：'+ data.show);
      });
   });
   layui.use('tree', function(){
      var data = [
         {
            title:"常住人口信息",
            children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"},
               {title:"国家和地区"},
               {title:"行政区划代码"},
               {title:"民族代码"},
               {title:"宗教信仰代码"},
               {title:"学历代码"},
               {title:"政治面貌代码"},
               {title:"婚姻状况代码"},
               {title:"兵役状况代码"},
               {title:"职业类别代码"},
               {title:"职业"},
               {title:"职务"},
               {title:"个人身份代码"},
               {title:"专长代码"},
               {title:"中文水平"},
               {title:"籍贯_国家和地区"},
               {title:"籍贯"},
               {title:"籍贯_地址名称"},
               {title:"出生地"},
               {title:"出生地区划"},
               {title:"出生地_地址名称"},
               {title:"户籍区划"},
               {title:"户籍地址名称"},
               {title:"户籍地责任区代码"},
               {title:"县级公安机关代码"},
               {title:"县级公安机关名称"},
               {title:"警务责任区代码"},
               {title:"人员住址编号"},
               {title:"现住址_住址编号"},
               {title:"现住址区划"},
               {title:"现住址_地址名称"},
               {title:"现住址_街路巷代码"},
               {title:"现住址_门（楼）牌号"},
               {title:"现住址_门（楼）详细地址"},
               {title:"其他住址区划"},
               {title:"其他住址"},
               {title:"服务处所"},
               {title:"联系电话"},
               {title:"人员DNA编号"},
               {title:"十指指纹编号"},
               {title:"死亡日期"},
               {title:"是否注销"},
               {title:"历史一_姓名"},
               {title:"历史一_姓名汉语拼音"},
               {title:"历史身份证"},
               {title:"历史二_姓名"},
               {title:"历史二_姓名汉语拼音"},
               {title:"历史二_身份号码"},
               {title:"户类型代码"},
               {title:"户号"},
               {title:"户主_姓名"},
               {title:"与户主关系代码"},
               {title:"父亲_姓名"},
               {title:"父亲_姓名汉语拼音"},
               {title:"父亲_身份号码"},
               {title:"母亲_姓名"},
               {title:"母亲_姓名汉语拼音"},
               {title:"母亲_身份号码"},
               {title:"配偶_姓名"},
               {title:"配偶_姓名汉语拼音"},
               {title:"配偶_身份号码"},
               {title:"监护人一_家庭关系代码"},
               {title:"监护人一_姓名"},
               {title:"监护人一_姓名汉语拼音"},
               {title:"监护人一_身份号码"},
               {title:"监护人二_家庭关系代码"},
               {title:"监护人二_姓名"},
               {title:"监护人二_姓名汉语拼音"},
               {title:"监护人二身份号码"},
               {title:"出生证明编号"},
               {title:"死亡证明编号"},
               {title:"来自地_国家和地区"},
               {title:"来自地区划"},
               {title:"来自地_地址名称"},
               {title:"来本市原因"},
               {title:"来本市时间"},
               {title:"变动日期"},
               {title:"变动原因"},
               {title:"变动类型"},
               {title:"变动区划代码"},
               {title:"变动_地址名称"},
               {title:"变动公安机关代码"},
               {title:"人口信息级别代码"},
               {title:"最后_受理时间"},
               {title:"最后_更新时间"},
               {title:"登记时间"},
               {title:"登记单位_公安机关机构代码"},
               {title:"登记单位_公安机关名称"},
               {title:"登记人_姓名"},
               {title:"登记人_公民身份号码"},
               {title:"登记人_联系电话"},
               {title:"操作标识"},
               {title:"操作时间"},
               {title:"操作单位_公安机关机构代码"},
               {title:"操作单位_公安机关名称"},
               {title:"操作人_姓名"},
               {title:"操作人_公民身份号码"},
               {title:"操作人_联系电话"},
               {title:"信息来源_行政区划代码"},
               {title:"首次_信息入库时间"},
               {title:"信息入库时间"},
               {title:"常住人口比较标识"},
               {title:"常住人口姓氏"},
               {title:"人员状态"},
               {title:"所属派出所机构代码"},
               {title:"所属派出所名称"},
               {title:"所属省级单位代码"},
               {title:"所属省市县（区）"},
               {title:"相片ID"},
               {title:"信息级别"},
               {title:"注销日期"},
               {title:"照片"}

            ]
         },
         {title:"常住人口注销信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"爆炸事故信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"爆炸事故单位信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"爆炸事故人员信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"收缴捡拾登记物品信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"涉爆案件收缴捡拾登记信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"涉爆案件的信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"涉爆案件单位信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"涉爆案件人员信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"涉爆案件物品信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"涉爆案件收缴存储人员信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"涉爆案件收缴信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"涉爆案件停产停业信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"涉爆案件违章登记人员信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"涉爆案件违章登记信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"涉爆案件违章项目信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"涉爆物品地面站信息",children:[

               {title:"信息主键编号"},
               {title:"人员编号"},
               {title:"姓名"},
               {title:"姓名汉语拼音"},
               {title:"外文姓"},
               {title:"外文名"},
               {title:"曾用名"},
               {title:"曾用名汉语拼音"},
               {title:"别名/绰号"},
               {title:"别名/绰号汉语拼音"},
               {title:"性别代码"},
               {title:"出生日期"},
               {title:"身份证"},
               {title:"常用证件代码"},
               {title:"证件号码"},
               {title:"身高"},
               {title:"血型代码"}

            ]},
         {title:"涉爆物品地面站储存品种数量表"},
         {title:"涉爆物品购买证信息"},
         {title:"涉爆物品购买证物品信息"},
         {title:"涉爆物品运输证信息"},
         {title:"涉爆物品运输证物品信息"},
         {title:"爆破作业工作人员基本信息"},
         {title:"爆破作业人员变更记录信息"},
         {title:"爆破作业人员证件信息"},
         {title:"爆破工程技术人员信息"},
         {title:"爆破工程技术人员单位变更记录信息"},
         {title:"涉爆重点人员信息"},
         {title:"公枪枪证信息"},
         {title:"公枪人员信息"},
         {title:"公枪持枪证信息"},
         {title:"民枪登记信息"},
         {title:"民枪人员情况信息"},
         {title:"民枪单位持枪证信息"},
         {title:"民枪个人持枪证信息"},
         {title:"枪支配购证信息"},
         {title:"枪支运输证信息"},
         {title:"制贩枪支重点人口信息"},
         {title:"民枪配售企业信息"},
         {title:"民枪配售企业人员信息"},
         {title:"民枪配置单位信息"},
         {title:"民枪配置单位人员信息"},
         {title:"民枪制造企业信息"},
         {title:"民枪制造企业人员信息"},
         {title:"实有人口信息"},
         {title:"门楼牌号地址信息"},
         {title:"暂住人口信息"},
         {title:"寄住人口信息"},
         {title:"流出人员信息"},
         {title:"流动人口信息"},
         {title:"身份证办理信息"},
         {title:"人员住址变动信息"},
         {title:"人户分离信息"},
         {title:"未落常住户口人员信息"},
         {title:"工作对象信息"},
         {title:"重点人口信息"},
         {title:"重点人口吸毒信息"},
         {title:"重点人口分析评估信息"},
         {title:"重点人员控制力量信息"},
         {title:"常住人口户口迁移信息"},
         {title:"帮教对象信息"},
         {title:"流浪乞讨人员信息"},
         {title:"精神病人员信息"},
         {title:"矫正对象信息"},
         {title:"两牢释放人员信息"},
         {title:"户信息"},
         {title:"房屋信息"},
         {title:"房屋承租人信息"},
         {title:"机构基本信息"},
         {title:"机构从业人员信息"},
         {title:"娱乐场所登记信息"},
         {title:"旅店同住人员信息"},
         {title:"印章企业信息"},
         {title:"行政案件信息"},
         {title:"旅店信息"},
         {title:"小广告采集信息"},
         {title:"小广告图像信息"},
         {title:"听证信息"},
         {title:"检测信息"},
         {title:"旅馆住宿人员信息"},
         {title:"国内旅客住宿信息"},
         {title:"境外旅客住宿信息"}
      ];
      var tree = layui.tree;
      tree.render({
         elem: '#dataTree'
         ,data: data
         ,accordion: true
         ,click: function(obj){

         }
      });
   });
   var AUTOCOMPLETE_TABLES = {
      'hello': ['world', 'neighbor', 'there'],
      'reply': ['rumble', 'hellodley', 'hi_there']
   }

   function fake_post(url, data, callback){
      // This structure is not specific to DataTable and is just the structure my server is returning.
      var response = {
         'type': 'table',
         'header': ['id', 'name'],
         'columns': [{'title': 'ID'}, {'title': 'Name'}],
         'data': [
            ['1', 'Homer Simpson'],
            ['2', 'Bart Simpson'],
            ['3', 'Lisa Simpson'],
            ['4', 'Ned Flanders'],
            ['5', 'Planet Earth']
         ]
      }

      callback(response);
   }
   function toggleSQL(){
      $("#sql-form").toggle();
      var dom = document.getElementById("toggleSQL");
      $(dom).children("i").css("fa fa-angle-double-down");
      if($(dom).children("i").hasClass("fa-angle-double-down")){
         $(dom).children("i").removeClass("fa-angle-double-down").addClass("fa fa-angle-double-up");
      }else {
         $(dom).children("i").removeClass("fa-angle-double-up").addClass("fa fa-angle-double-down");
      }
   }

   function run_sql(){
       $('#data-container').show();
       $('#data-error').removeClass("layui-show");
       var sql = window.editor.getValue();
       layui.use('table', function(){
           var table = layui.table;
           table.render({
               elem: '#demo'
               ,url: '/sql/runSql'
               ,where:{sql:sql}
               ,method:'post'
               ,page: true //开启分页
               ,cellMinWidth: 100 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
               ,height: 500
               ,cols: [[
                   { type:'numbers',align:'center', width:60,title:'序号'}
                   ,{field:'access',  title: '字段名称',align:'center',width:'18%'}
               ]],
               done:function (res,page,count) {
                   var myData=new Array();
                   myData = res.data.columndata;
                   table.init('userFilter',{//转换成静态表格
                       cols:[myData]
                       ,data:res.data.data
                       ,limit:10
                   });
                   fake_post("editor/run-sql", {'data': sql}, function(result){
                       // $("#data-container").html(htmlinfo);
                       toggleSQL();
                   });
               }
           });
       });
   }

   window.onload = function() {

      window.editor = CodeMirror.fromTextArea(document.getElementById('code'), {
         mode: 'text/x-mysql',
         indentWithTabs: true,
         smartIndent: true,
         lineNumbers: true,
         matchBrackets : true,
         autofocus: true,
         extraKeys: {"Ctrl-Space": "autocomplete"}
      });

       window.editor.setSize('auto','auto');

      CodeMirror.commands.autocomplete = function(cm) {
         CodeMirror.showHint(cm, CodeMirror.hint.sql, {
            tables: AUTOCOMPLETE_TABLES
         });
      }
   };
</script>



</BODY>
</HTML>
